# coding: utf-8
'''
Created on 24 avr. 2011

@author: shin
'''
import unittest
from business.Damier import Damier
from stub.DaoDamier  import DaoDamier
from stub.Observer   import Observer

class Test(unittest.TestCase):

    def setUp(self):
        self.damier = Damier(DaoDamier("niveau1"))
        self.damier._uiDamierLink = Observer()

    def tearDown(self):
        del self.damier

    def test_init_X(self):
        self.assertEqual(self.damier.height, 8)
        
    def test_init_Y(self):
        self.assertEqual(self.damier.width, 10)
        
    def test_init_Position(self):
        self.assertEqual(len(self.damier._position), 80)

    def test_initiailsePosition(self):
        self.assertEqual(self.damier._position.__contains__("A1"), True)
        self.assertEqual(self.damier._position.__contains__("J7"), True)
        self.assertEqual(self.damier._position.__contains__("K1"), False)
        self.assertEqual(self.damier._position.__contains__("A9"), False)   
    
    def test_retire(self):
        self.damier.place("perso1", "A1")
        self.damier.retire("perso1")
        self.assertEqual(self.damier._position["A1"], [])

    def test_place(self):
        self.damier.place("perso1", "A1")
        self.assertEqual(self.damier.donnePosition("perso1"), "A1")
        
    def test_changementPlace_1(self):
        self.damier.place("perso1", "A1")
        self.damier.place("perso1", "A2")
        self.assertEqual(self.damier.donnePosition("perso1"), "A2")

    def test_changementPlace_2(self):
        self.damier.place("perso1", "A1")
        self.damier.place("perso1", "A2")
        self.assertEqual(self.damier.contenu("A1"), [])

    def test_donneContenu(self):
        self.damier.place("perso1", "B6")
        self.damier.place("perso2", "B6")
        self.assertEqual(self.damier.contenu("B6"), ["perso1", "perso2"])

    def test_caseContientJoueur(self):
        self.assertEqual


if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()

